package com.warm.base.design.b_mediator;

import java.util.ArrayList;
import java.util.List;

/**
 * @Date: 2019/11/22 15:23
 * @Author: LChuang
 * @Description:
 */
public class ConcreteMediator extends Mediator {

    private List<Colleague> colleagues = new ArrayList<>();

    @Override
    public void register(Colleague colleague) {
        if(!colleagues.contains(colleague)){
            colleagues.add(colleague);
        }
    }

    @Override
    public void relay(Colleague colleague) {
        for (Colleague item : colleagues){
            if(!item.equals(colleague)){
                item.receive();
            }
        }
    }
}
